package com.byxy.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.byxy.entity.Agency;
import com.byxy.entity.Guide;
import com.byxy.service.GuideService;

public class GuideAddAction {
	@Resource
	private GuideService guideService;

	private Integer id; // 序号
	private String name; // 名字
	private String phone; // 电话
	private String qq; // QQ
	private String remark;// 备注
	private Integer sex; // 性别
	private Integer agencyId; // 旅行社Id

	private String email; // email

	private List<Agency> agencys;

	public List<Agency> getAgencys() {
		return agencys;
	}

	public void setAgencys(List<Agency> agencys) {
		this.agencys = agencys;
	}

	public String add() {
		if ("POST".equalsIgnoreCase(ServletActionContext.getRequest().getMethod())) {

			Agency agency = new Agency();
			if(agencyId == null)
				agency = null;
			else
				agency.setId(agencyId);
			boolean bSex = sex == 0 ? false : true;
			Guide guide = new Guide(id, name, phone, email, bSex, agency, qq, remark);
			guideService.save(guide);
			return "success";
		} else {
			agencys = guideService.findAgency();
			return "get";
		}
	}

	public Integer getAgencyId() {
		return agencyId;
	}

	public String getEmail() {
		return email;
	}

	public GuideService getGuideService() {
		return guideService;
	}

	public Integer getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getPhone() {
		return phone;
	}

	public String getQq() {
		return qq;
	}

	public String getRemark() {
		return remark;
	}

	public Integer getSex() {
		return sex;
	}

	public void setAgencyId(Integer agencyId) {
		this.agencyId = agencyId;
	}

	// public Agency getAgency() {
	// return agency;
	// }
	//
	// public void setAgency(Agency agency) {
	// this.agency = agency;
	// }

	public void setEmail(String email) {
		this.email = email;
	}

	public void setGuideService(GuideService guideService) {
		this.guideService = guideService;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

}
